package com.mkyong.template.action;

import java.util.ArrayList;
import java.util.List;
	
import com.mkyong.template.bo.TemplateBo;
import com.mkyong.template.model.Template;
import com.opensymphony.xwork2.ActionSupport;
	
	public class TemplateAction extends ActionSupport {
		
	    Template template = new Template();
	    List<Template> tempList = new ArrayList<Template>();
	    
	    TemplateBo templateBo;
	    
	  //DI via Spring
		public void setTemplateBo(TemplateBo templateBo) {
			this.templateBo = templateBo;
		}
		
		public Object getModel() {
			return template;
		}
		
		public List<Template> getTempList() {
			return tempList;
		}

		public void setTempList(List<Template> templateList) {
			this.tempList = templateList;
		}
		
		//save Template
		public String addTemplate() throws Exception{
			
			//save it
			templateBo.addTemplate(template);		
			return "success";
		
		} 
	    
	}